package main

import (
	"fmt"
	"sync"
	"time"
)
var wg sync.WaitGroup
func test(num int){
	// 调用完成
	defer wg.Done()
	for i :=0;i<10;i++{
		fmt.Println("协程",num,i)
		fmt.Printf("协程(%v)打印的第%v条数据",num,i)
		time.Sleep(time.Millisecond*300)
	}
}
func main() {

	for i:=1;i<=6;i++{
			// 主线程等待
			wg.Add(1)
		go test(i)
	}
	wg.Wait()
	fmt.Println("关闭主线程...")
	

}